import Cookies from 'js-cookie'

const USERINFO = 'weilaixiaozhao_template_userinfo'

// Token
export function setUserInfo(userInfo, time) { return Cookies.set(USERINFO, JSON.stringify(userInfo || {}), { expires: time || 1 }) }

export function getUserInfo() {
  return JSON.parse(Cookies.get(USERINFO) || '{}')
}

export function removeUserInfo() {
  // 删除后台cookie
  Cookies.remove('PHPSESSID')
  Cookies.remove('username')
  Cookies.remove('password')
  return Cookies.remove(USERINFO)
}
